package operator;

public class ExceptionDemo {

    public static void main(String[] args) {
        int[] arr = {23, 14, 56, 9, 10, 7, 33, 47, 21, 20, 18, 17, 55, 63};

        for (int i = 0; i <= arr.length; i++) {
            System.out.print(arr[i] + " ");  //由于循环条件误写为：i<=arr.length,最后异常循环时会抛出ArrayIndexOutOfBoundsException异常。
        }


        arr = null;
        for (int i = 0; i <= arr.length; i++) {
            System.out.print(arr[i] + " ");  //由于arr=null并不指向任何对象，打印元素时会抛出NullPointerException
        }
    }
}
